
var _oErrors =
{
sNoSelectedEntity:		LOCID_IMPORT_NOSELENTITY,
sNoFile:				LOCID_IMPORT_NOFILE,
sFileHasChanged:		LOCID_IMPORT_FILEHASCHANGED
};




function importSelectedCustomizations()
{
var aImportItems = getSelected("gridImport");




if (aImportItems.length == 0)
{
alert(_oErrors.sNoSelectedEntity);
return;
}

if(confirm(LOCID_IMPORT_WARNING))
{
importCustomizations(aImportItems);
}
}





function importAllCustomizations()
{
var aImportItems = getAll("gridImport");



if (aImportItems.length == 0)
{
alert(_oErrors.sNoFile);
return;
}

if(confirm(LOCID_IMPORT_WARNING))
{
importCustomizations(aImportItems);
}
}





function importCustomizations(aImportItems)
{

var uploadForm = this.parent.FormFrame.UploadForm;
var uploadedFileName = uploadForm.fileName.value;
var currentFileName = uploadForm.userFile.value;

if (uploadedFileName != currentFileName)
{
alert(_oErrors.sFileHasChanged);
return;
}





var entityName, entityType;

var importListXml = "<importexportxml><entities>";
for (var i = 0; i < aImportItems.length; i++)
{
entityType = aImportItems[i].split(":")[0];
entityName = aImportItems[i].split(":")[1];

if (entityType != null && entityType == "entity")
importListXml += "<entity>" + entityName + "</entity>";
}

importListXml += "</entities><nodes>";

for (var i = 0; i < aImportItems.length; i++)
{
entityType = aImportItems[i].split(":")[0];
entityName = aImportItems[i].split(":")[1];

if (entityType != null && entityType == "node")
importListXml += "<node>" + entityName + "</node>";
}

importListXml += "</nodes><settings>";

for (var i = 0; i < aImportItems.length; i++)
{
entityType = aImportItems[i].split(":")[0];
entityName = aImportItems[i].split(":")[1];

if (entityType != null && entityType == "setting")
importListXml += "<setting>" + entityName + "</setting>";
}

importListXml += "</settings><securityroles>";

for (var i = 0; i < aImportItems.length; i++)
{
entityType = aImportItems[i].split(":")[0];
entityName = aImportItems[i].split(":")[1];

if (entityType != null && entityType == "securityrole")
importListXml += "<securityrole>" + entityName + "</securityrole>";
}

importListXml += "</securityroles><workflows>";

for (var i = 0; i < aImportItems.length; i++)
{
entityType = aImportItems[i].split(":")[0];
entityName = aImportItems[i].split(":")[1];

if (entityType != null && entityType == "workflow")
importListXml += "<workflow>" + entityName + "</workflow>";
}

importListXml += "</workflows></importexportxml>";



uploadForm.action.value = "upload-process";
uploadForm.target = "StatusFrame";
uploadForm.importList.value = importListXml;
uploadForm.importJobId.value = GetGuid();


this.parent.StatusFrame.document.body.innerText = "";


setTimeout(this.parent.FormFrame.showStatusDialog, 100);


this.parent.FormFrame.document.body.onbeforeunload = null;
uploadForm.submit();
}
